package com.yl.pattern.creatormodel.factory.before;

/**
 * @Author 小羊
 * @Date 29/10/2024下午 8:18
 * @ClassName CoffeeStore
 * @Description CoffeeStore
 */
public class CoffeeStore {
    public Coffee orderCoffee(String type){
        //声明Coffee类型的对象，根据不同的类型创建对象
        Coffee coffee;
        if("american".equals(type)){
            coffee = new AmericanCoffee();
        }else if("latte".equals(type)){
            coffee = new LatteCoffee();
        }else {
            throw new RuntimeException("对不起，你所点的咖啡没有");
        }
        //加配料
        coffee.addMilk();
        coffee.addSugar();

        return coffee;
    }
}
